<template>
  <ant-modal modalWidth="1000" modalHeight="600" :visible="open" :modal-title="formTitle" :adjust-size="true" :maskClosable="false"
    @cancel="cancel">
    <a-form-model ref="form" :model="form" :rules="rules" slot="content" layout="vertical">
      <a-row :gutter="32">
        <a-col :span="12" v-if="form.projectId">
          <a-form-model-item label="项目编号">
            <a-input v-model="form.projectNumber" readOnly />
          </a-form-model-item>
        </a-col>
        <a-col :span="12">
          <a-form-model-item label="订单编号">
            <a-input v-model="form.orderNumber" readOnly />
          </a-form-model-item>
        </a-col>
        <a-col :span="12">
          <a-form-model-item label="客户">
            <a-input v-model="form.customerName" v-if="disabled" :disabled='disabled' />
            <a-select v-else
              placeholder="请选择客户"
              v-model="form.customerId"
              :getPopupContainer="
                triggerNode => {
                  return triggerNode.parentNode || document.body
                }
              "
              style="width: 100%"
              allow-clear
              show-search
              optionFilterProp="children"
            >
              <a-select-option v-for="(d, index) in customerIdOptions" :key="index" :value="d.id">{{ d.customerName }}</a-select-option>
            </a-select>
          </a-form-model-item>
        </a-col>
        <a-col :span="12">
          <a-form-model-item label="送货地址">
            <a-input v-model="form.address" v-if="disabled" :disabled='disabled' />
            <a-input v-model="form.address" v-else />
          </a-form-model-item>
        </a-col>
        <a-col :span="12">
          <a-form-model-item label="业主电话">
            <a-input v-model="form.phone" v-if="disabled" :disabled='disabled' />
            <a-input v-model="form.phone" v-else />
          </a-form-model-item>
        </a-col>
        <a-col :span="12">
          <a-form-model-item label="备注">
            <a-input v-model="form.remark" v-if="disabled" :disabled='disabled' />
            <a-input v-model="form.remark" v-else />
          </a-form-model-item>
        </a-col>
        <a-col :span="12">
          <a-form-model-item label="备注">
            {{ disabled }}
          </a-form-model-item>
        </a-col>
        <a-col :span="24">
          <a-card :bordered="false">
            <!-- 选择工序 -->
            <biz-order-plan-form v-if="showPlanModal" ref="bizOrderPlanForm" @ok="getList" @close="showPlanModal = false" />

            <a-tabs v-model="activeKey">
              <a-tab-pane key="1" tab="产品明细">
                <advance-table :key="`productList${disabled}`" :loading="loading" rowKey="id" size="middle" :columns="disabled ? columns3 : columns" :data-source="productList"
              :pagination="false" :bordered="true">
              <!-- <span slot="amountSlot" slot-scope="{record}">
                {{ record.number * record.price }}
              </span> -->
              
              
              <span slot="numberSlot" slot-scope="{record}">
                    <a-input @change='changeNumber(record)' type='number' placeholder="请输入" v-model="record.number" />
                  </span>
            
                <span slot="remarkSlot" slot-scope="{record}">
                  <a-input  placeholder="请输入备注" v-model="record.remark" />
                </span>
                <span slot="priceSlot" slot-scope="{record}">
                  <a-input-number  placeholder="请输入单价" v-model="record.price" />
                </span>
                

                <span slot="unitSlot" slot-scope="{record}">
              <a-select
                placeholder="请选择单位"
                v-model="record.unit"
                :getPopupContainer="
                  triggerNode => {
                    return triggerNode.parentNode || document.body
                  }
                "
                style="width: 100%"
                allow-clear
                @change='changeUnit(record)'
              >
                <a-select-option v-for="(d, index) in record.unitList" :key="index" :value="d.key">{{ d.name }}</a-select-option>
              </a-select>
            </span>
                <span slot="operation" slot-scope="{record}">
                  <a  @click="handleSubDelete(record)" v-hasPermi="['system:dict:remove']">
                    删除
                  </a>
                </span>
            </advance-table>
              </a-tab-pane>
              <a-tab-pane key="2" tab="物料明细">
                <advance-table :loading="loading" rowKey="id" size="middle" :columns="columns2" :data-source="materialList"
              :pagination="false" :bordered="true">
              <span slot="number2Slot" slot-scope="{record}">
                <a-input @change='changeNumber2(record)' type='number' placeholder="请输入" v-model="record.number2" />
              </span>
            </advance-table>
              </a-tab-pane>
            </a-tabs>
          </a-card>
        </a-col>
      </a-row>

    </a-form-model>
    <template slot="footer">
      <a-button type="primary" @click="modify" v-if="disabled == true">
        修改
      </a-button>
      <a-button type="primary" @click="submitForm(true)" v-if="disabled == false">
        保存
      </a-button>
      <a-button type="primary" @click="audit(form,2)" v-if="form.orderStatus == 1" v-hasPermi="['biz:bizPurchase:audit']">
        审核
      </a-button>
      <a-button type="primary" @click="audit(form,1)" v-if="form.orderStatus > 1" v-hasPermi="['biz:bizPurchase:audit']">
        反审
      </a-button>
      <a-button type="danger" @click="handleDelete(form)">
        删除
      </a-button>
      <a-button @click="cancel">
        取消
      </a-button>
    </template>
  </ant-modal>
</template>
<script>
import BizOrderForm from './BizOrderForm'
export default {
  ...BizOrderForm,

}
</script>
<style lang="less" scoped>
.table-operations,
body tr.ant-table-expanded-row:hover .table-operations {
  padding-bottom: 8px;
  text-align: right;
}

.table-operations {
  margin-bottom: 16px;
}

.table-operations>button,
.table-operations .ant-input-affix-wrapper {
  margin-right: 8px;
}

.table_title {
  float: left;
  padding-left: 8px;
  font-weight: 600;
  color: #222222;
  line-height: 30px;
}
</style>
